//package invest.strategy.impl;
//
//import invest.data.DataEnum;
//import invest.data.DataFactory;
//import invest.pojo.ToSendRecord;
//import invest.pojo.datapojo.StockHistory;
//import invest.pojo.datapojo.YejiYuBao;
//import invest.utils.DateUtil;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.Date;
//import java.util.List;
//
//@Component
//public class YejiyubaoFind extends AbstractStrategy {
//    {
//        super.cron = "0 30 9 ? * *";
//    }
//
//    DataFactory dataFactory = new DataFactory();
//
//    @Override
//    protected void setMail() {
//        mail.setSubject("查询业绩预报");
//        mail.setContent("查询业绩预报过去100个交易日没有暴涨80%，过去5个交易日存在一天涨了超过3%，预计扣非净利润增加35%以上，上市超过了300个交易日");
//    }
//
//    @Override
//    public boolean analyzeStrategy() throws Exception {
//        boolean flag = false;
//        List<YejiYuBao> yejiYuBaos = (List<YejiYuBao>) dataFactory.getData(DataEnum.YEJIYUBAO);
//        for (YejiYuBao yejiyubao : yejiYuBaos
//        ) {
//            if (yejiyubao.getAddAmpLower() > 30 && DateUtil.getDayDiffer(yejiyubao.getNoticeDate(), new Date()) < 60) {
//                DataFactory dataFactory1 = new DataFactory(yejiyubao.getCode());
//                List<StockHistory> stockHistories = (List<StockHistory>) dataFactory1.getData(DataEnum.STOCK_HISTORY);
//                if (stockHistories.size() > 200) {
//                    List<Double> prices = new ArrayList<>();
//                    for (int i = 0; i < 100; i++) {
//                        prices.add(stockHistories.get(i).getClosingPrice());
//                    }
//                    Double maxPercent = getMaxPercent(prices);
//                    if (maxPercent < 0.6) {
//                        for (int i = 0; i < 5; i++) {
//                            if (stockHistories.get(i).getRiseRange() > 3) {
//                                ToSendRecord record = new ToSendRecord();
//                                record.setName(yejiyubao.getName());
//                                record.setMessage("利润率增长："+yejiyubao.getAddAmpLower());
//                                this.setToSendTarget(record);
//                                flag = true;
//                            }
//                        }
//                    }
//                }
//
//            }
//        }
//        return flag;
//    }
//
//    private Double getMaxPercent(List<Double> prices) {
//
//        Double maxPrice = Collections.max(prices);
//        Double minPrice = Collections.min(prices);
//        Double percent = (maxPrice - minPrice) / minPrice;
//        return percent;
//    }
//
//
//}
